home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / dkbtrace / pbmplus / source / libtiff / tiffiop.h < prev   
Encoding:
C/C++ Source or Header  |  1991-08-19  |  9.1 KB  |  264 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffioP.h,v 1.13 91/08/19 14:40:23 sam Exp $ */
  2.  
  3. /*
  4.  * Copyright (c) 1988, 1989, 1990, 1991 Sam Leffler
  5.  * Copyright (c) 1991 Silicon Graphics, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26.  
  27. #ifndef _TIFFIOP_
  28. #define    _TIFFIOP_
  29. /*
  30.  * ``Library-private'' definitions.
  31.  */
  32. #include "tiffcompat.h"
  33. #include "tiff.h"
  34.  
  35. /*
  36.  * Internal format of a TIFF directory entry.
  37.  */
  38. typedef    struct {
  39.     u_long    td_imagewidth, td_imagelength, td_imagedepth;
  40.     u_long    td_tilewidth, td_tilelength, td_tiledepth;
  41.     u_short    td_subfiletype;
  42.     u_short    td_bitspersample;
  43.     u_short    td_datatype;
  44.     u_short    td_compression;
  45.     u_short    td_photometric;
  46.     u_short    td_threshholding;
  47.     u_short    td_fillorder;
  48.     u_short    td_orientation;
  49.     u_short    td_samplesperpixel;
  50.     u_short    td_predictor;
  51.     u_long    td_rowsperstrip;
  52.     u_long    td_minsamplevalue, td_maxsamplevalue;    /* maybe float? */
  53.     float    td_xresolution, td_yresolution;
  54.     u_short    td_resolutionunit;
  55.     u_short    td_planarconfig;
  56.     float    td_xposition, td_yposition;
  57.     u_long    td_group3options;
  58.     u_long    td_group4options;
  59.     u_short    td_pagenumber[2];
  60.     u_short    td_grayresponseunit;
  61.     u_short    td_colorresponseunit;
  62.     u_short    td_matteing;
  63.     u_short    td_inkset;
  64.     u_short    td_cleanfaxdata;
  65.     u_short    td_badfaxrun;
  66.     u_long    td_badfaxlines;
  67.     u_short    *td_grayresponsecurve;
  68.     u_short    *td_redresponsecurve;
  69.     u_short    *td_greenresponsecurve;
  70.     u_short    *td_blueresponsecurve;
  71.     u_short    *td_redcolormap;
  72.     u_short    *td_greencolormap;
  73.     u_short    *td_bluecolormap;
  74.     char    *td_documentname;
  75.     char    *td_artist;
  76.     char    *td_datetime;
  77.     char    *td_hostcomputer;
  78.     char    *td_imagedescription;
  79.     char    *td_make;
  80.     char    *td_model;
  81.     char    *td_software;
  82.     char    *td_pagename;
  83.     u_long    td_fieldsset[2];    /* bit vector of fields that are set */
  84.     u_long    td_stripsperimage;
  85.     u_long    td_nstrips;        /* size of offset & bytecount arrays */
  86.     u_long    *td_stripoffset;
  87.     u_long    *td_stripbytecount;
  88. #ifdef JPEG_SUPPORT
  89.     u_short    td_jpegproc;
  90.     u_short    td_jpegprec;
  91.     u_short    **td_qtab;
  92.     u_char    **td_dctab;
  93.     u_char    **td_actab;
  94. #endif
  95. } TIFFDirectory;
  96.  
  97. /*
  98.  * Field flags used to indicate fields that have
  99.  * been set in a directory, and to reference fields
  100.  * when manipulating a directory.
  101.  */
  102. /* multi-entry fields */
  103. #define    FIELD_IMAGEDIMENSIONS        0
  104. #define FIELD_TILEDIMENSIONS        1
  105. #define    FIELD_CELLDIMENSIONS        2        /* XXX */
  106. #define    FIELD_RESOLUTION        3
  107. #define    FIELD_POSITION            4
  108. /* single-entry fields */
  109. #define    FIELD_SUBFILETYPE        5
  110. #define    FIELD_BITSPERSAMPLE        6
  111. #define    FIELD_COMPRESSION        7
  112. #define    FIELD_PHOTOMETRIC        8
  113. #define    FIELD_THRESHHOLDING        9
  114. #define    FIELD_FILLORDER            10
  115. #define    FIELD_DOCUMENTNAME        11
  116. #define    FIELD_IMAGEDESCRIPTION        12
  117. #define    FIELD_MAKE            13
  118. #define    FIELD_MODEL            14
  119. #define    FIELD_ORIENTATION        15
  120. #define    FIELD_SAMPLESPERPIXEL        16
  121. #define    FIELD_ROWSPERSTRIP        17
  122. #define    FIELD_MINSAMPLEVALUE        18
  123. #define    FIELD_MAXSAMPLEVALUE        19
  124. #define    FIELD_PLANARCONFIG        20
  125. #define    FIELD_PAGENAME            21
  126. #define    FIELD_GRAYRESPONSEUNIT        22
  127. #define    FIELD_GRAYRESPONSECURVE        23
  128. #define    FIELD_GROUP3OPTIONS        24
  129. #define    FIELD_GROUP4OPTIONS        25
  130. #define    FIELD_RESOLUTIONUNIT        26
  131. #define    FIELD_PAGENUMBER        27
  132. #define    FIELD_COLORRESPONSEUNIT        28
  133. #define    FIELD_COLORRESPONSECURVE    29
  134. #define    FIELD_STRIPBYTECOUNTS        30
  135. #define    FIELD_STRIPOFFSETS        31
  136. #define    FIELD_COLORMAP            32
  137. #define FIELD_PREDICTOR            33
  138. #define FIELD_ARTIST            34
  139. #define FIELD_DATETIME            35
  140. #define FIELD_HOSTCOMPUTER        36
  141. #define FIELD_SOFTWARE            37
  142. #define    FIELD_MATTEING            38
  143. #define    FIELD_BADFAXLINES        39
  144. #define    FIELD_CLEANFAXDATA        40
  145. #define    FIELD_BADFAXRUN            41
  146. #define FIELD_DATATYPE            42
  147. #define FIELD_IMAGEDEPTH        43
  148. #define FIELD_TILEDEPTH            44
  149. #define FIELD_INKSET            45
  150. #define    FIELD_LUMACOEFS            46
  151. #define FIELD_YCBCRSAMPLING        47
  152. #define FIELD_JPEGPROC            48
  153. #define FIELD_JPEGQTABLEPREC        49
  154. #define FIELD_JPEGQTABLES        50
  155. #define FIELD_JPEGDCTABLES        51
  156. #define FIELD_JPEGACTABLES        52
  157. #define    FIELD_LAST            52
  158.  
  159. #define BITFIELDn(tif, n)        ((tif)->tif_dir.td_fieldsset[(n)/32]) 
  160. #define BITn(n)                (((unsigned)1L)<<((n)&0x1f)) 
  161. #define TIFFFieldSet(tif, field)    (BITFIELDn(tif, field) & BITn(field)) 
  162. #define TIFFSetFieldBit(tif, field)    (BITFIELDn(tif, field) |= BITn(field))
  163. #define TIFFClrFieldBit(tif, field)    (BITFIELDn(tif, field) &= ~BITn(field))
  164.  
  165. struct tiff {
  166.     char    *tif_name;        /* name of open file */
  167.     short    tif_fd;            /* open file descriptor */
  168.     short    tif_mode;        /* open mode (O_*) */
  169.     char    tif_fillorder;        /* natural bit fill order for machine */
  170.     char    tif_options;        /* compression-specific options */
  171.     short    tif_flags;
  172. #define    TIFF_DIRTYHEADER    0x1    /* header must be written on close */
  173. #define    TIFF_DIRTYDIRECT    0x2    /* current directory must be written */
  174. #define    TIFF_BUFFERSETUP    0x4    /* data buffers setup */
  175. #define    TIFF_BEENWRITING    0x8    /* written 1+ scanlines to file */
  176. #define    TIFF_SWAB        0x10    /* byte swap file information */
  177. #define    TIFF_NOBITREV        0x20    /* inhibit bit reversal logic */
  178. #define    TIFF_MYBUFFER        0x40    /* my raw data buffer; free on close */
  179. #define    TIFF_ISTILED        0x80    /* file is tile, not strip- based */
  180. #define    TIFF_MAPPED        0x100    /* file is mapped into memory */
  181.     long    tif_diroff;        /* file offset of current directory */
  182.     long    tif_nextdiroff;        /* file offset of following directory */
  183.     TIFFDirectory tif_dir;        /* internal rep of current directory */
  184.     TIFFHeader tif_header;        /* file's header block */
  185.     int    tif_typeshift[6];    /* data type shift counts */
  186.     long    tif_typemask[6];    /* data type masks */
  187.     long    tif_row;        /* current scanline */
  188.     int    tif_curstrip;        /* current strip for read/write */
  189.     long    tif_curoff;        /* current offset for read/write */
  190. /* tiling support */
  191.     long     tif_col;        /* current column (offset by row too) */
  192.     int     tif_curtile;        /* current tile for read/write */
  193.     long     tif_tilesize;        /* # of bytes in a tile */
  194. /* compression scheme hooks */
  195.     int    (*tif_predecode)();    /* pre row/strip/tile decoding */
  196.     int    (*tif_preencode)();    /* pre row/strip/tile encoding */
  197.     int    (*tif_postencode)();    /* post row/strip/tile encoding */
  198.     int    (*tif_decoderow)();    /* scanline decoding routine */
  199.     int    (*tif_encoderow)();    /* scanline encoding routine */
  200.     int    (*tif_decodestrip)();    /* strip decoding routine */
  201.     int    (*tif_encodestrip)();    /* strip encoding routine */
  202.     int    (*tif_decodetile)();    /* tile decoding routine */
  203.     int    (*tif_encodetile)();    /* tile encoding routine */
  204.     int    (*tif_close)();        /* cleanup-on-close routine */
  205.     int    (*tif_seek)();        /* position within a strip routine */
  206.     int    (*tif_cleanup)();    /* routine called to cleanup state */
  207.     char    *tif_data;        /* compression scheme private data */
  208. /* input/output buffering */
  209.     int    tif_scanlinesize;    /* # of bytes in a scanline */
  210.     int    tif_scanlineskew;    /* scanline skew for reading strips */
  211.     char    *tif_rawdata;        /* raw data buffer */
  212.     long    tif_rawdatasize;    /* # of bytes in raw data buffer */
  213.     char    *tif_rawcp;        /* current spot in raw buffer */
  214.     long    tif_rawcc;        /* bytes unread from raw buffer */
  215. #ifdef MMAP_SUPPORT
  216.     char*    tif_base;        /* base of mapped file */
  217.     long    tif_size;        /* size of mapped file region (bytes) */
  218. #endif
  219. };
  220.  
  221. #define    isTiled(tif)    (((tif)->tif_flags & TIFF_ISTILED) != 0)
  222. #ifdef MMAP_SUPPORT
  223. #define    isMapped(tif)    (((tif)->tif_flags & TIFF_MAPPED) != 0)
  224. #else
  225. #define    isMapped(tif)    0        /* force dead code */
  226. #endif
  227.  
  228. /* generic option bit names */
  229. #define    TIFF_OPT0    0x1
  230. #define    TIFF_OPT1    0x2
  231. #define    TIFF_OPT2    0x4
  232. #define    TIFF_OPT3    0x8
  233. #define    TIFF_OPT4    0x10
  234. #define    TIFF_OPT5    0x20
  235. #define    TIFF_OPT6    0x40
  236. #define    TIFF_OPT7    0x80
  237.  
  238. #include "tiffio.h"
  239.  
  240. /* NB: the u_int casts are to silence certain ANSI-C compilers */
  241. #ifdef howmany
  242. #undef howmany
  243. #endif
  244. #define    howmany(x, y)    ((((u_int)(x))+(((u_int)(y))-1))/((u_int)(y)))
  245. #ifdef roundup
  246. #undef roundup
  247. #endif
  248. #define    roundup(x, y)    (howmany(x,y)*((u_int)(y)))
  249.  
  250. #if defined(c_plusplus) || defined(__cplusplus) || defined(__STDC__) || USE_PROTOTYPES
  251. #if defined(__cplusplus)
  252. extern "C" {
  253. #endif
  254. extern    int TIFFNoEncode(TIFF*, u_char*, int, u_int);
  255. extern    int TIFFNoDecode(TIFF*, u_char*, int, u_int);
  256. #if defined(__cplusplus)
  257. }
  258. #endif
  259. #else
  260. extern    int TIFFNoEncode();
  261. extern    int TIFFNoDecode();
  262. #endif
  263. #endif /* _TIFFIOP_ */
  264.